package org.base23.order.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.HashMap;
import java.util.Map;
import org.base23.commons.utils.JSON;
import org.base23.web.exception.Exceptions;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order/test")
@Tag(name = "订单测试", description = "订单服务测试接口")
public class OrderController {

  @GetMapping
  @Operation(summary = "测试订单接口", description = "返回测试数据并打印当前用户信息")
  public Map<String, Object> testOrder() {
    Object userLoginInfo = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    System.out.println("用户登录信息：" + JSON.stringify(userLoginInfo));

    HashMap<String, Object> data = new HashMap<>();
    data.put("code", 200);
    data.put("msg", "success");
    data.put("data", "testData");
    return data;
  }

}
